<?php
session_start();

if(!isset($_SESSION['userid']))//检查 userid 是否已经设置，如果没有设置，提示未登录并跳转首页
{
    echo "<script>alert('您尚未登录！')</script>";
    echo "<script>window.location.href='index.php'</script>";

}

$userid=$_SESSION['userid'];
include ('mysqli_connect.php');

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>影视管理系统</title>
    <link rel="stylesheet" href="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
    <script src="http://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
    <script src="http://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <style>
        body{
            width: 100%;
            height:auto;

        }
        #query{
            text-align: center;
        }
    </style>
</head>

<body>
<nav class="navbar navbar-default navbar-static-top" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
            <a class="navbar-brand" href="#">我的影视库</a>
        </div>
        <div>
            <ul class="nav navbar-nav">

                <li><a href="user_index.php">主页</a></li>
                <li><a href="user_querymovie.php">影视查询</a></li>
                <li class="active"><a href="user_sheet.php">我的收藏</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">个人信息<b class="caret"></b></a>

                    <ul class="dropdown-menu">
                        <li><a href="user_info.php">用户信息</a></li>
                        <li><a href="user_repass.php">修改密码</a></li>
                    </ul>
                </li>
                <li><a href="index.php">退出</a></li>
            </ul>
        </div>
    </div>
</nav>



<h1 style="text-align: center"><strong>当前所有收藏影视单</strong></h1>
<br>
<div style="text-align:center">
<a class="btn btn-default btn-lg" href="user_add_newsheet.php" role="button">添加新影单</a>
</div>
<br>
<table  width='100%' class="table table-condensed">
    <tr>
        <th>影单ID</th>
        <th>影视单名称</th>
        <th>电影数</th>
        <th>详情</th>
        <th>删除</th>

    </tr>



<?php

    $sql = "select movie_sheet_id,count(movie_id) num from movie_sheet_table where user_id='6' group by movie_sheet_id;";

    //$sql="select * from movie_sheet_table;";
    $res=mysqli_query($dbc,$sql);
    //$row['movie_id']!= 0 是为了防止页面把默认的id为0的那个记录也显示出来了。
    while ($row = mysqli_fetch_assoc($res)){
        $realnum = $row["num"] - 1;
        #$realnum=10;
        echo "<tr>";
        echo "<td>{$row['movie_sheet_id']}</td>";
        $sql_b = "select *
            from movie_sheet_table 
            where movie_sheet_id='{$row['movie_sheet_id']}';";
        //$sql="select * from movie_sheet_table;";
        $res_b=mysqli_query($dbc,$sql_b);
        $row_b = mysqli_fetch_assoc($res_b);
        echo "<td>{$row_b['sheet_name']}</td>";
        echo "<td>{$realnum}</td>";
//        echo "<td>{$row['release_time']}</td>";
//        echo "<td>{$row['movie_language']}</td>";
//        echo "<td>{$row['movie_duration']}</td>";
//        echo "<td>{$row['movie_Chinese_name']}</td>";
//        echo "<td>{$row['movie_English_name']}</td>";
//        echo "<td>{$row['movie_marking']}</td>";
//        echo "<td>{$row['movie_intro']}</td>";
//        echo "<td>{$row['marking_content']}</td>";
        //echo "<td>{$row['class_name']}</td>";
        //echo "<td>{$row['pressmark']}</td>";
        //if($row['state']==1) echo "<td>在馆</td>"; else if($row['state']==0) echo "<td>已借出</td>";else  echo "<td>无状态信息</td>";
//        echo "<td><a href='admin_book_edit.php?id={$row['movie_id']}'>修改</a></td>";
//        echo "<td><a href='admin_book_del.php?id={$row['movie_id']}'>删除</a></td>";
        echo "<td><a href='user_sheet_detail.php?sheetid={$row['movie_sheet_id']}'>查看详情</a></td>";
        echo "<td><a href='user_delete_sheet.php?sheetid={$row['movie_sheet_id']}'>删除影单</a></td>";
        //if($row['state']==1)echo "<td><a href='admin_book_jiechu.php?id={$row['book_id']}'>借阅</a></td>";
        //if($row['state']==0)echo "<td><a href='admin_book_guihuan.php?id={$row['book_id']}'>归还</a></td>";
        echo "</tr>";
    }
?>
